Skip to content

Method: computeNextMove(int, KopfundZahlPlayer, KopfundZahlState)

1: package de.fhdw.gaming.ipspiel22.kopfundzahl.strategy;
2:
3: import java.util.Optional;
4:
5: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlPlayer;
6: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlState;
7: import de.fhdw.gaming.ipspiel22.kopfundzahl.domain.KopfundZahlStrategy;
8: import de.fhdw.gaming.ipspiel22.kopfundzahl.moves.KopfundZahlMove;
9: import de.fhdw.gaming.ipspiel22.kopfundzahl.moves.factory.KopfundZahlMoveFactory;
10:
11: /**
12: * Implements {@link KopfundZahlStrategy} by always saying "Head".
13: */
14: public final class KopfundZahlKopfStrategy implements KopfundZahlStrategy {
15:
16: /**
17: * The factory for creating KopfundZahl moves.
18: */
19: private final KopfundZahlMoveFactory moveFactory;
20:
21: /**
22: * Creates an {@link KopfundZahlKopfStrategy}.
23: *
24: * @param moveFactory The factory for creating KopfundZahl moves.
25: */
26: public KopfundZahlKopfStrategy(final KopfundZahlMoveFactory moveFactory) {
27: this.moveFactory = moveFactory;
28: }
29:
30: @Override
31: public Optional<KopfundZahlMove> computeNextMove(final int gameId, final KopfundZahlPlayer player,
32: final KopfundZahlState state) {
33: return Optional.of(this.moveFactory.createHeadMove());
34: }
35:
36: @Override
37: public String toString() {
38: return KopfundZahlKopfStrategy.class.getSimpleName();
39: }
40: }